package StudyCode.summary.mycollection;

import java.util.HashMap;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class GetIntersectionBetweenTwoHashMap {
	public static <T, F> HashMap<T, F> getIntersection(HashMap<T, F> map1,
	                                                   HashMap<T, F> map2) {
		HashMap<T, F> map = new HashMap<T, F>();

		for (T elem : map1.keySet())
			if (map2.containsKey(elem)
					&& map2.get(elem).equals(map1.get(elem)))
				map.put(elem, map1.get(elem));
		return map;
	}
}
